package com.itcoon.transform.base.definition;

import java.util.List;

public class InjectDefinition {

    private Object injectMode;
    private List<?> attributeSources;

    private String attribute;

    public InjectDefinition(String attribute, Object injectMode, List<?> attributeSources) {
        this.attribute = attribute;
        this.injectMode = injectMode;
        this.attributeSources = attributeSources;
    }

    public InjectDefinition() {
    }

    public Object getInjectMode() {
        return injectMode;
    }

    public void setInjectMode(Object injectMode) {
        this.injectMode = injectMode;
    }

    public List<?> getAttributeSources() {
        return attributeSources;
    }

    public void setAttributeSources(List<?> attributeSources) {
        this.attributeSources = attributeSources;
    }

    public String getAttribute() {
        return attribute;
    }

    public void setAttribute(String attribute) {
        this.attribute = attribute;
    }

    @Override
    public String toString() {
        return "InjectContext{" +
                "injectMode=" + injectMode +
                ", attributeSources=" + attributeSources +
                ", attribute='" + attribute + '\'' +
                '}';
    }

    public InjectInfo getInfo(int index) {
        Object attributeSource = null;
        if (attributeSources != null && attributeSources.size() > 0) {
            attributeSource = attributeSources.get(index);
        }
        return new InjectInfo(attribute, injectMode, attributeSource);
    }


    public static class InjectInfo {

        private String attribute;

        private Object injectMode;

        private Object attributeSource;

        public InjectInfo(String attribute, Object injectMode, Object attributeSource) {
            this.attribute = attribute;
            this.injectMode = injectMode;
            this.attributeSource = attributeSource;
        }

        public String getAttribute() {
            return attribute;
        }

        public void setAttribute(String attribute) {
            this.attribute = attribute;
        }

        public Object getInjectMode() {
            return injectMode;
        }

        public void setInjectMode(Object injectMode) {
            this.injectMode = injectMode;
        }

        public Object getAttributeSource() {
            return attributeSource;
        }

        public void setAttributeSource(Object attributeSource) {
            this.attributeSource = attributeSource;
        }
    }
}
